#include "maker_base.h"
// uint8_t tap1[] = {0x2a, 0xab, 0x43, 0xf6, 0x03, 0xb4};
// uint8_t tap0[] = {0xbe, 0x26, 0x55, 0xa5, 0xce, 0x34};
int main()
{
    // 打开tap1网卡接口

    char tap_name[] = "tap1";
    int fd = open("/dev/net/tun", O_RDWR);
    struct ifreq ifr;
    memset(&ifr, 0, sizeof(struct ifreq));
    strncpy(ifr.ifr_ifrn.ifrn_name, tap_name, sizeof(tap_name));
    ifr.ifr_ifru.ifru_flags = IFF_TAP | IFF_NO_PI;
    if (ioctl(fd, TUNSETIFF, &ifr) != 0)
    {
        perror(strerror(errno));
        exit(errno);
    };
    uint8_t sender_hw_a[6] = {0x2a, 0xab, 0x43, 0xf6, 0x03, 0xb4};
    uint8_t target_hw_a[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
    uint8_t sender_p_a[4] = {192, 168, 2, 152};
    uint8_t target_p_a[4] = {192, 168, 2, 1};

    struct arp_pck pck = arp_maker(sender_hw_a, sender_p_a, target_hw_a, target_p_a);
    while (1)
    {
        /* code */
        DEBUG_PRINT("sizeof(struct arp_pck) %zd",sizeof(struct arp_pck));
        write(fd,&pck,sizeof(struct arp_pck));
        sleep(1);
    }
    
}